﻿@model Stardust.Models.UsuarioViewModelCreate

@{
    ViewBag.Title = "Registrar Cliente";
}

<h2>@ViewBag.Title</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Ubigeo.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var cmbDepartamento = $('#idDepartamento');
        cmbDepartamento.val('');
    });
</script>
<br />

@if (Html.ValidationSummary() != null)
{
<div class="nNote nWarning hideit">
    <p>@Html.ValidationSummary()</p>
</div>
}

@using (Html.BeginForm("Create", "Usuario", FormMethod.Post, new { @class = "form" } ))
{
    <fieldset>
        <div class = "widget" >
            <div class = "title" >
                <img src="@Url.Content("~/Content/images/icons/dark/list.png")" alt class="titleIcon">
                <h6>@ViewBag.Title</h6>
            </div>
            
            <div class = "formRow" style = "display:none;"  >
                <div class = "formRight" >
                    <input name = "fechaRegistro" id = "fechaRegistro" value = @DateTime.Now/>
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.idPerfilUsuario )
                <div class = "formRight" >
                    @Html.DropDownListFor( model => model.idPerfilUsuario , new SelectList( Model.PerfilesUsuario, "ID" , "nombre" ) , "Elije un perfil..." )
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    @Html.ValidationMessageFor(model => model.idPerfilUsuario)
                </div>
                <div class = "clear" ></div>
            </div>

            <div>
                @for (int i = 0; i < Model.PerfilesUsuario.Count; i++)
                {
                    @Html.HiddenFor(m => m.PerfilesUsuario[i].ID)
                    @Html.HiddenFor(m => m.PerfilesUsuario[i].nombre)
                }
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.user_account )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.user_account )
                    @Html.ValidationMessageFor(model => model.user_account)
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.pass )
                <div class = "formRight" >
                    @Html.PasswordFor( model => model.pass )
                    @Html.ValidationMessageFor( model => model.pass )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.nombres )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.nombres )
                    @Html.ValidationMessageFor( model => model.nombres )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.apPat )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.apPat )
                    @Html.ValidationMessageFor( model => model.apPat )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.apMat )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.apMat )
                    @Html.ValidationMessageFor( model => model.apMat )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.email )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.email )
                    @Html.ValidationMessageFor( model => model.email )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.celular )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.celular )
                    @Html.ValidationMessageFor( model => model.celular )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.tipoDocumento )
                <div class = "formRight" >
                    @Html.DropDownListFor( model => model.tipoDocumento , new SelectList( Model.Documentos, "nombre" , "nombre") , "Elije un tipo de documento..." )
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    @Html.ValidationMessageFor( model => model.tipoDocumento )
                </div>
                <div class = "clear" ></div>
            </div>

            <div>
                @for (int i = 0; i < Model.Documentos.Count; i++)
                {
                    @Html.HiddenFor(m => m.Documentos[i].nombre)
                }
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.nroDocumento )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.nroDocumento )
                    @Html.ValidationMessageFor( model => model.nroDocumento )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.razonSocial )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.razonSocial )
                    @Html.ValidationMessageFor( model => model.razonSocial )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.direccion )
                <div class = "formRight" >
                    @Html.TextBoxFor( model => model.direccion )
                    @Html.ValidationMessageFor( model => model.direccion )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.idDepartamento )
                <div class = "formRight" >
                    @Html.DropDownListFor(model => model.idDepartamento, new SelectList(Model.Departamentos, "ID", "nombre"), "Elije un departamento...")
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    @Html.ValidationMessageFor( model => model.idDepartamento )
                </div>
                <div class = "clear" ></div>
            </div>

            <div>
                @for (int i = 0; i < Model.Departamentos.Count; i++)
                {
                    @Html.HiddenFor(m => m.Departamentos[i].ID)
                    @Html.HiddenFor(m => m.Departamentos[i].nombre)
                }
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.idProvincia )
                <div class = "formRight" >
                    @Html.DropDownListFor(model => model.idProvincia, Enumerable.Empty<SelectListItem>(), "Elije un departamento primero...") 
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    @Html.ValidationMessageFor( model => model.idProvincia )
                </div>
                <div class = "clear" ></div>
            </div>

            <div class = "formRow" >
                @Html.LabelFor( model => model.idDistrito )
                <div class = "formRight" >
                    @Html.DropDownListFor(model => model.idDistrito, Enumerable.Empty<SelectListItem>(), "Elije una provincia primero...") 
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    @Html.ValidationMessageFor( model => model.idDistrito )
                </div>
                <div class = "clear" ></div>
            </div>

        </div>
        <p>
            <input class = "redB" type="submit" value="Crear" /> |
            @Html.ActionLink("Regresar", "Index")
        </p>
    </fieldset>
}